import {
  INIT_BUYCART,
  GET_USERINFO,
  RECORD_USERINFO,
  ADD_ANIMATION,
  CHANGE_NAV,
 	SET_MENU_LIST
} from './mutation-types'
import { setStore, getStore } from '../utils/storage'
export default {
  // 记录用户信息
  [RECORD_USERINFO] (state, info) {
    state.userInfo = info
    state.login = true
    setStore('userInfo', info)
  },
  // 获取用户信息
  [GET_USERINFO] (state, info) {
    if (state.userInfo && (state.userInfo.username !== info.username)) {
      return
    }
    if (!state.login) {
      return
    }
    if (!info.message) {
      state.userInfo = {...info}
    } else {
      state.userInfo = null
    }
  },
  [CHANGE_NAV](state,index){		//修改首页导航下标
  	state.navIndex = index
  },
  [SET_MENU_LIST](state,menuList){
  	state.menuList = menuList;
  }
}
